package com.financing.wap.service.impl;


import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.financing.wap.common.BizEnums.CommonEnums;
import com.financing.wap.dao.IFpFaUserAddressDao;
import com.financing.wap.dto.FpFaUserAddressDTO;
import com.financing.wap.service.IFpFaUserAddressService;
import com.financing.wap.util.DTOdateSetUtil;
/**
 * fp_fa_user_address  
 * 理财师-地址管理 业务访问层实现类
 * @author huqiyun
 *
 */
 
@Repository("fpFaUserAddressService")
public class FpFaUserAddressServiceImpl implements IFpFaUserAddressService{

	@Autowired
	private IFpFaUserAddressDao fpFaUserAddressDao;

	@Override
	public int insert(FpFaUserAddressDTO fpFaUserAddress) throws SQLException {
		DTOdateSetUtil.setCreateInfo(fpFaUserAddress);
		DTOdateSetUtil.setUpdateInfo(fpFaUserAddress);
		fpFaUserAddress.setDeleteTag(CommonEnums.VALID_FLAG_1);
		return fpFaUserAddressDao.insert(fpFaUserAddress);
	}

	@Override
	public void update(FpFaUserAddressDTO fpFaUserAddress) throws SQLException {
		DTOdateSetUtil.setUpdateInfo(fpFaUserAddress);
		fpFaUserAddressDao.update(fpFaUserAddress);
	}

	@Override
	public void updateForce(FpFaUserAddressDTO fpFaUserAddress) throws SQLException {
		DTOdateSetUtil.setUpdateInfo(fpFaUserAddress);
		fpFaUserAddressDao.updateForce(fpFaUserAddress);
	}

	@Override
	public void delete(Integer id) throws SQLException {
		fpFaUserAddressDao.delete(id);
	}
	
	@Override
	public List<FpFaUserAddressDTO> queryList(FpFaUserAddressDTO fpFaUserAddress) throws SQLException {
		return fpFaUserAddressDao.queryList(fpFaUserAddress);
	}

	@Override
	public int queryListCount(FpFaUserAddressDTO fpFaUserAddress) throws SQLException {
		return fpFaUserAddressDao.queryListCount(fpFaUserAddress);
	}

	@Override
	public FpFaUserAddressDTO loadById(Integer id) throws SQLException {
		return fpFaUserAddressDao.loadById(id);
	}
 	@Override
	public FpFaUserAddressDTO queryListGetFirst(FpFaUserAddressDTO fpFaUserAddress)
			throws SQLException {
		 List<FpFaUserAddressDTO> queryList = queryList(fpFaUserAddress);
		 if(queryList==null||queryList.size()==0){
			 return new FpFaUserAddressDTO();
		 }
		 return queryList.get(0);
	}
}
